import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class code2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] nums = new int[n];
        for(int i=0;i<n;i++) {
            nums[i] = in.nextInt();
        }
        int[] dp = new int[n+1];

        for(int i=2;i<n+1;i++) {
            dp[i] = Math.min(dp[i-1]+nums[i-1],dp[i-2]+nums[i-2]);
        }
        if(n==1) System.out.println(nums[0]);
        else if(n==2) System.out.println(Math.min(nums[0],nums[1]));
        else System.out.println(dp[n]);
    }
}